package org.ims.inv.service.system;

import java.util.List;

import org.ims.inv.model.system.ModelAppUser;
import org.ims.inv.model.system.ModelAppUserProfile;

import cn.trymore.core.exception.ServiceException;
import cn.trymore.core.service.ServiceGeneric;
import cn.trymore.core.web.paging.PaginationSupport;
import cn.trymore.core.web.paging.PagingBean;

/**
 * Service: 系统用户
 * 
 * @author Jeccy.Zhao
 *
 */
public interface ServiceAppUser
extends ServiceGeneric<ModelAppUser>
{
	/**
	 * Obtains user with the specified user name.
	 * 
	 * @param userName
	 *            the user name
	 * @return user entity if existed with the specified user name; null returned otherwise.
	 * @throws ServiceException
	 */
	ModelAppUser findByUserName (String userName) throws ServiceException;
	
	/**
	 * Obtains user with the specified user no.
	 * 
	 * @param userNo
	 *            the user no
	 * @return user entity if existed with the specified user name; null returned otherwise.
	 * @throws ServiceException
	 */
	ModelAppUser findByUserNo (String userNo) throws ServiceException;
	
	/**
	 * Obtains user with the specified search text, e.g. user name or user No.
	 * 
	 * @param search
	 * @return
	 * @throws ServiceException
	 */
	List<ModelAppUser> findByUserNameORUserNo (String search) throws ServiceException;
	
	/**
	 * Obtains pagination of users by profile
	 * 
	 * @param profile
	 * @param pagingBean
	 * @return
	 * @throws ServiceException
	 */
	PaginationSupport<ModelAppUser> findByUserProfile (ModelAppUserProfile profile, PagingBean pagingBean) throws ServiceException;
	
	/**
	 * Obtains user with the specified user ids
	 * 
	 * @param userIds
	 * @return
	 * @throws ServiceException
	 */
	List<ModelAppUser> findByUserIDs (String[] userIds) throws ServiceException;
	
	/**
	 * Obtains user with provided password
	 * @param userName
	 * @return user entity
	 */
	ModelAppUser getPasswordByUserName (String userName) throws ServiceException;
	
	/**
	 * Obtains user with the specified user role
	 * 
	 * @param roleKey
	 * @return
	 * @throws ServiceException
	 */
	List<ModelAppUser> findByUserRole (String roleKey) throws ServiceException;
	
	/**
	 * Remove user with the specified user id
	 * 
	 * @param uid
	 * @throws ServiceException
	 */
	void removeUser (String uid) throws ServiceException;
	
	/**
	 * Obtains all of users (root user excluded.)
	 * 
	 * @return
	 * @throws ServiceException
	 */
	List<ModelAppUser> getAllUsers () throws ServiceException;
	
}
